<template>
	<div class="coupon-box" v-if="!!couponList.length" :style="{'background-image': 'url('+imgHost+'/statics/coupon_bck.png)'}">
		<div v-if="modelData.title || modelData.titleDesc" class="coupon-title">
			<span class="title">{{ modelData.title }}</span>
			<span v-if="modelData.titleDesc" class="line">|</span>
			<span class="desc">{{ modelData.titleDesc }}</span>
		</div>
		<ul class="coupon-ul" :style="{ paddingTop: modelData.title || modelData.titleDesc ? '4rpx' : '46rpx' }">
			<view v-for="(item, index) in couponList" :key="index" class="coupon-li" :class="[modelData.rowNum === 2 ? 'coupon-two-li' : '']">
				<div class="coupon-in" @click="getCoupon(item)">
					<p class="num">¥{{ Number(item.reducePrice) }}</p>
					<div class="coupon-desc" v-if="Number(item.minPrice)">商品满{{ Number(item.minPrice) }}元可用</div>
					<div class="coupon-desc" v-else>无使用门槛</div>
					<div class="get-btn">
						<span>领取使用</span>
						<span class="ibonfont ibonyoujiantou"></span>
					</div>
				</div>
			</view>
		</ul>
	</div>
</template>

<script>
import webUrl from '@/config.js';
export default {
	name: 'CouponGroup',
	data(){
		return {
			imgHost : webUrl.QN_URL
		}
	},
	props: {
		modelData: {
			type: Object,
			default: () => {
				return {};
			}
		},
		couponList: {
			type: Array,
			default: () => {
				return [];
			}
		}
	},
	methods: {
		// 点击领取优惠券
		async getCoupon(item) {
			this.$u.api
				.receive({
					couponId: item.id,
					vipCardId: item.vipCardId
				})
				.then(res => {
					this.$api.msg('领取成功');
				});
		}
	}
};
</script>
<style scoped lang="scss">
.coupon-box {
	border-radius: 32rpx;
	width: 710rpx;
	margin: 0 auto;
	background-repeat: no-repeat;
	background-position: center;
	background-size: 100% 100%;
	.coupon-title {
		padding: 0 24rpx;
		line-height: 90rpx;
		height: 90rpx;
		color: #ffe6c6;
		font-size: 24rpx;
		.line {
			margin: 0 20rpx;
		}
		.title {
			font-size: 36rpx;
			font-weight: 600;
			color: #ffd7a4;
			text-shadow: 1px 4rpx 1px rgba(175, 19, 13, 0.51);
		}
	}
	.coupon-ul {
		padding-left: 8rpx;
		display: flex;
		padding-bottom: 46rpx;
		padding-top: 4rpx;
		width: 100%;
		// flex-wrap: wrap;
		white-space: nowrap;
		overflow-x: scroll;
		.coupon-li {
			padding: 4rpx;
			display: inline-block;
			margin-left: 24rpx;
			width: 200rpx;
			height: 280rpx;
			background: linear-gradient(180deg, #ffe3cb 3%, #fff8f2 100%);
			border-radius: 10rpx;
			&:last-child {
				margin-right: 30rpx;
			}
			.coupon-in {
				width: 192rpx;
				height: 272rpx;
				border-radius: 8rpx;
				border: 1px solid #a5837a;
				margin: 0 auto;
				text-align: center;
				.num {
					font-size: 48rpx;
					font-family: DIN-Medium, DIN;
					font-weight: 500;
					color: #8b3913;
					line-height: 38rpx;
					background: linear-gradient(180deg, #934331 0%, #c5785f 100%);
					-webkit-background-clip: text;
					-webkit-text-fill-color: transparent;
					margin-top: 52rpx;
				}
				.coupon-desc {
					font-size: 24rpx;
					font-weight: 400;
					color: #3c3c3c;
					line-height: 34rpx;
					margin-top: 16rpx;
				}
				.get-btn {
					width: 152rpx;
					height: 48rpx;
					line-height: 48rpx;
					background: #9e4722;
					border-radius: 40rpx;
					color: #ffffff;
					font-size: 20rpx;
					margin: 40rpx auto 0;
					.ibonfont {
						font-size: 20rpx;
						margin-left: 10rpx;
					}
				}
			}
		}
		.coupon-two-li {
			width: 308rpx;
			display: inline-block;
			.coupon-in {
				width: 300rpx;
				.get-btn {
					width: 172rpx;
				}
			}
		}
	}
}
</style>
